package org.nepu.scr.indexrate.converter.riskrate.equipmentdata;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.riskrate.equipmentdata.CommonInput;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class CommonInputConverter implements AttributeConverter<CommonInput, String> {
    @Override
    public String convertToDatabaseColumn(CommonInput commonInput) {
        return JSONUtil.toJsonStr(commonInput);
    }

    @Override
    public CommonInput convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, CommonInput.class);
    }
}
